package com.doge.service.admin.dashboard;

import com.doge.bean.pojo.goods.GoodsExample;
import com.doge.bean.pojo.goods.GoodsProductExample;
import com.doge.bean.pojo.order.OrderExample;
import com.doge.bean.pojo.user.UserExample;
import com.doge.bean.vo.DashboardVO;
import com.doge.mapper.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @program: project2-wechat-mall
 * @description: 首页实现接口
 * @author: zhu lei
 * @create: 2021-11-29 21:14
 **/
@Service
public class DashBoardServiceImpl implements DashBoardService {
    @Autowired
    UserMapper userMapper;

    @Autowired
    GoodsMapper goodsMapper;

    @Autowired
    GoodsProductMapper goodsProductMapper;

    @Autowired
    OrderMapper orderMapper;

    public DashboardVO dashboardVO(UserExample userExample, GoodsExample goodsExample, GoodsProductExample goodsProductExample,
                                   OrderExample orderExample) {
        long userTotal = userMapper.countByExample(userExample);
        long goodsTotal = goodsMapper.countByExample(goodsExample);
        long productTotal = goodsProductMapper.countByExample(goodsProductExample);
        long orderTotal = orderMapper.countByExample(orderExample);
        DashboardVO dashboardVO = new DashboardVO();
        dashboardVO.setGoodsTotal(goodsTotal);
        dashboardVO.setUserTotal(userTotal);
        dashboardVO.setProductTotal(productTotal);
        dashboardVO.setOderTotal(orderTotal);
        return dashboardVO;
    }
}